package com.coolw.spring.statemachine.controller;

import com.coolw.common.api.BaseResult;
import com.coolw.spring.statemachine.dto.OrderDTO;
import com.coolw.spring.statemachine.service.OrderService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 订单请求控制层
 *
 * @author coolw
 * @date 2024/4/8 18:00
 */
@RequestMapping("/order")
@RestController
public class OrderController {

    @Resource
    private OrderService orderService;

    /**
     * 创建订单
     */
    @PostMapping("/create")
    public BaseResult<String> create(@RequestBody OrderDTO orderDTO) {
        return orderService.create(orderDTO);
    }

    /**
     * 订单支付
     */
    @PostMapping("/pay/{orderId}")
    public BaseResult<Boolean> pay(@PathVariable String orderId) {
        return orderService.pay(orderId);
    }

    /**
     * 订单发货
     */
    @PostMapping("/deliver/{orderId}")
    public BaseResult<Boolean> deliver(@PathVariable String orderId) {
        return orderService.deliver(orderId);
    }

    /**
     * 订单确认收货
     */
    @PostMapping("/receive/{orderId}")
    public BaseResult<Boolean> receive(@PathVariable String orderId) {
        return orderService.receive(orderId);
    }
}
